const merge = require("webpack-merge");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const common = require("./webpack.common.js");
const webpack = require("webpack");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const { resolve } = require('path')

module.exports = merge(common, {
  output: {
    // 打包输出目录
    path: resolve(__dirname, 'dist'),
    filename:'js/[chunkhash].js',
    chunkFilename: 'js/[chunkhash].js'
  },
  plugins: [
    new CleanWebpackPlugin(["dist"]),
    new UglifyJsPlugin({
      cache: true,
      parallel: true,
      sourceMap: true
    }),
    new webpack.DefinePlugin({
      "process.env": {
        NODE_ENV: JSON.stringify('production')
      }
    })
  ]
});
